package mju.cxf.controller.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import mju.cxf.entity.Activity;
import mju.cxf.result.Result;
import mju.cxf.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/activity")
@Api("广告相关接口")
public class IActivityController {
    @Autowired
    private ActivityService activityService;
    /**
     * 主页轮播图
     */
    @GetMapping("/banner")
    @ApiOperation(value ="广告横幅" ,notes = "用户查看横幅")
    public Result<List<Activity>> getBanner() {
        LambdaQueryWrapper<Activity> lqw=new LambdaQueryWrapper<>();
        lqw.eq(Activity::getType,0).eq(Activity::getStatus,0);
        return Result.success(activityService.list(lqw));
    }
    @PostMapping("/activity")
    public Result<List<Activity>> getActivity(){
        LambdaQueryWrapper<Activity> lqw=new LambdaQueryWrapper<>();
        lqw.eq(Activity::getType,1).eq(Activity::getStatus,0);
        final List<Activity> activities = activityService.list(lqw);
        return Result.success(activities);
    }
}